Baseball, by the Rules
For more examples, click here.
Hit by Pitch
A hit by pitch is pretty much what it sounds like: instead of the batter hitting a pitch, the pitch hits the batter. When this happens, the batter is awarded first base. This is counted as a plate appearance, but not an at-bat. For the purposes of being hit by a pitch, any part of the batter counts, including their uniform. Indeed, if the pitch clips the batter’s jersey, but doesn’t hit their body proper, that still counts as a hit by pitch. It also counts if the ball bounces in the dirt on the way to hitting the batter, but not if it bounces off of something else (like the catcher’s mitt).
Now, there are still a couple of caveats. First, by rule, the umpire can nullify a hit by pitch if they feel that the batter did not make an effort to get out of the way. However, this is not enforced very often; indeed, it's a situation where the rule as written runs up against the practical considerations of actually playing baseball. On the one hand, batters frequently don’t have enough time to get out of the way of pitches headed in their direction. But, on the other hand, you will also frequently see batters wearing various pieces of padding or body armor on their hands/arms, leaning into close pitches in the hopes of drawing a free base. So while it's fairly rare, it's not unheard of to see an umpire wave off a hit by pitch and keep the batter at the plate. When this happens, the pitch just goes as a called ball— unless the other caveat comes into play.
The other caveat is that a hit by pitch cannot be called on a strike. If a batter gets hit on a pitch they swung at, well, that's too bad for them, and embarassing to boot. If a batter doesn't swing, but is leaning over the plate so much that they get by a ball that's in the strike zone, by rule, that pitch should be called a strike. This happens very rarely, however, and is called even more rarely still1. But, it is possible per the rules. Last but not least, if the ball hits the bat, and then hits the batter, it’s just a foul ball. If the ball hits a batter and then hits their bat, that’s a hit by pitch.
Most hit by pitches are accidental, but not all of them are. Baseball has a long history of pitchers retaliating for perceived aggressions by plunking an opponent or two. If an umpire judges that a HBP was intentional, they can immediately throw the offending pitcher out of a game. Even if they stop short of that, once tempers start rising, umpires will typically issue a warning to both teams, to the tune of “hey, knock this stuff off.” Once warnings are issued, subsequent HBPs (or pitches that come close to being HBPs) can result in ejections2.